#ifndef INCLUDED_MAP_H
#define INCLUDED_MAP_H

#include<SGE.h>
using namespace SGE;
class Map
{
public:
	Map();
	~Map();

	void Load(const char* pLevel,const char* pTexturePack);
	void Unload();
	void Update(float deltaTime);
	void Render(const SVector2& viewOffset);

	bool TestCollision(const SLineSegment& segment, SRect& rect) const;
	
	int GetWidth() const  { return mColumns * mTileSize; }
	int GetHeight() const { return mRows * mTileSize; }

private: 
	bool LoadLevel(const char* pLevel);
	bool LoadTexturePack(const char* pTexturePack);

	int GetIndex(int x, int y) const;
	bool IsBlocked(int x, int y) const;
	SRect GetBoundingBox(int x, int y) const;

	SGE_Sprite* mpSprites;
	int* mpTiles;

	int mNumSprites;
	int mTileSize;
	int mColumns;
	int mRows;
};

#endif //INCLUDED_MAP_H
